package model

import "gorm.io/gorm"

type User struct {
	gorm.Model
	UserName    string `json:"user_name" form:"user_name"`
	Password    string `json:"password" form:"password"`
	Phone       string `json:"phone" form:"phone"`
	Age         uint   `json:"age" form:"age"`
	Sex         string `json:"sex" form:"sex"`
	RoleID      uint   `json:"role_id" form:"role_id"`
	FamilyID    uint   `json:"family_id" form:"family_id"`
	Signature   string `json:"signature" form:"signature"`
	Email       string `json:"email" form:"email"`
	Reservation []Reservation
	Work        []Work    `gorm:"many2many:user_works;"`
	Subsidy     []Subsidy `gorm:"many2many:user_subsidy;"`
}
type Family struct {
	gorm.Model
	HouseOwner string `json:"house_owner"`
	//家庭人数
	Sum      int    `json:"sum"`
	RegionID uint   `json:"region_id"`
	Address  string `json:"address"`
	User     []User
	House    []House
}
type House struct {
	gorm.Model
	Height    string `json:"height"`
	Area      string `json:"area"`
	HouseName string `json:"house_name"`
	Address   string `json:"address"`
	Picture   string `json:"picture"`
	FamilyID  uint   `json:"family_id"`
	RegionID  uint   `json:"region_id"`
}

//地区
type Region struct {
	gorm.Model
	Area     string `json:"area"`
	Name     string `json:"name"`
	Describe string `json:"describe"`
	Family   []Family
}

//资源
type Subsidy struct {
	gorm.Model
	SubsidyName    string `json:"subsidy_name"`
	SubsidiesImage string `json:"subsidies_image"`
	ResourceTypeID uint   `json:"resource_type_id"`		
	Amount         int    `json:"amount"`
	Money          int    `json:"money"`
	Describe       string `json:"describe"`
}

type Work struct {
	gorm.Model
	WorkName string `json:"work_name"`
	WorkImage string `json:"work_image"`
	ResourceTypeID uint   `json:"resource_type_id"`
	Amount         int    `json:"amount"`
	Money          int    `json:"money"`
	Describe       string `json:"describe"`
}

type Reservation struct {
	gorm.Model
	ReservationName string `json:"reservation_name"`
	ResourceID uint `json:"resource_id"`
	UserID     uint `json:"user_id"`
	//1为通过 0为不通过
	Status       int    `json:"status"`
	CheckMsg     string `json:"check_msg"`
	ResourceType int    `json:"resource_type"`
	Describe     string `json:"describe"`
}

type Role struct {
	ID   uint   `json:"id" gorm:"primaryKey"`
	Name string `json:"name"`
	User []User
}

type ResourceType struct {
	ID      uint   `json:"id" gorm:"primaryKey"`
	Name    string `json:"name"`
	Work    []Work
	Subsidy []Subsidy
}

type OneTitle struct {
	ID       uint       `json:"id" gorm:"primaryKey"`
	Title    string     `json:"title"`
	Path     string     `json:"path"`
	TwoTitle []TwoTitle `json:"two_title"`
}

type TwoTitle struct {
	ID         uint   `json:"id" gorm:"primaryKey"`
	Title      string `json:"title"`
	Path       string `json:"path"`
	OneTitleID uint   `json:"one_title_id"`
}
